﻿using System;
using System.Linq;
using Autodesk.Revit.DB;
using YJKRevitKernel.ElementSearchUtility.LinkDocumentSuite;
using YJKPatternSign.StairsRoomSection.DataDefine;
using YJKPatternSign.StairsRoomSection.Kit;

namespace YJKPatternSign.StairsRoomSection.ElementPacket
{
	public sealed class ColumnObject : ElementObject
	{
		public ColumnObject(BaseLinkDocumentResultBean LinkElem, SectionViewData secviewData = null) : base(LinkElem, secviewData)
		{
			this.m_objectType = ObjectType.kStructColumnType;
		}

		public override void GetMaterial()
		{
			Parameter parameter = base.SelfElem.UseElement.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM);
			if (parameter != null)
			{
				Material material = base.SelfElem.UseElement.Document.GetElement(parameter.AsElementId()) as Material;
				if (material != null)
				{
					this.m_strMaterial = material.Name;
					return;
				}
			}
			else
			{
				Document document = base.SelfElem.UseElement.Document;
				ElementId typeId = base.SelfElem.UseElement.GetTypeId();
				parameter = document.GetElement(typeId).GetParameters("材质").FirstOrDefault<Parameter>();
				if (parameter != null)
				{
					Material material2 = base.SelfElem.UseElement.Document.GetElement(parameter.AsElementId()) as Material;
					if (material2 != null)
					{
						this.m_strMaterial = material2.Name;
					}
				}
			}
		}
	}
}
